if(localStorage.getItem("game")){
  gameList = JSON.parse(localStorage.getItem("game"))
}

//消息弹窗
function showMessage(text) {
  const messageElement = document.getElementById('message');
  messageElement.children[0].textContent = text;
  messageElement.classList.add('show');
  setTimeout(() => {
      messageElement.classList.remove('show');
  }, 800);
}

function openModal(title, content) {
  const modal = document.getElementById('talk');
  const modalTitle = document.getElementById('modal-title');
  const modalContent = document.getElementById('modal-content');

  // 设置弹出框的标题和内容
  modalTitle.textContent = title;
  modalContent.textContent = content;

  // 显示弹出框
  modal.style.display = 'block';
}

function closeModal() {
  const modal = document.getElementById('talk');
  // 隐藏弹出框
  modal.style.display = 'none';
}
function copyModal(){
  const modaltext = document.getElementById('modal-content').innerText.split('：')[1].trim();
  copyToClipboard(modaltext)
  closeModal()
}


const bgElement = document.getElementById('bg');
        const backgroundImages = [
            "./img/bg1.png",
            "./img/bg2.png",
            "./img/bg3.png"
        ];
        let currentIndex = 0;
        function changeBackground() {
            currentIndex = (currentIndex + 1) % backgroundImages.length;
            const nextImage = backgroundImages[currentIndex];
            bgElement.style.backgroundImage = `url('${nextImage}')`;
            localStorage.setItem("bgimage", backgroundImages[currentIndex]);
        }

const qiebg = document.getElementById("qiehuan");
qiebg.addEventListener("click", changeBackground);

function closeSheZhi(){
  qiebg.style.display = "none";
}
function showSheZhi(){
  qiebg.style.display = "block";
}

if(localStorage.getItem("bgimage")){
  bgElement.style.backgroundImage = "url(" + localStorage.getItem("bgimage") + ")";
}